package sgi.client;

import java.io.IOException;

import sgi.message.MessageSearch;

public class SGISearchArchiveController extends SGIController {
	
	private static SGISearchArchiveController search;
	private static SGISearchArchiveUI searchUI;
	
	public static SGISearchArchiveController create()
	{
		if(SGISearchArchiveController.search == null)
		{
			search = new SGISearchArchiveController();
			searchUI.setController(search);
		}
		
		searchUI.setVisible(true);
		return search;
	}
	
	private SGISearchArchiveController()
	{
		searchUI = new SGISearchArchiveUI();
	}
	
	public void search(String dateFrom,String dateTo,String location)
	{
		MessageSearch msg = new MessageSearch(dateFrom,dateTo,location);
	}
	
	public void search(String dateFrom,String dateTo)
	{
		MessageSearch msg = new MessageSearch(dateFrom,dateTo);
		sendSearch(msg);
	}
	
	
	private void sendSearch(MessageSearch msg)
	{
		try {
			(SGIClientConnectionController.createConnection()).handleMessageFromClientUI(msg);
		} catch  (IOException e) {e.printStackTrace();}
	}
	
	@Override
	void handleMessage(Object msg) {
		// TODO Auto-generated method stub
		
	}
	
	
	

}
